#include "stdafx.h"
#include "UIManager.h"

#include <algorithm>


UIManager::UIManager()
{
}

UIManager::~UIManager()
{
    Check();
}

void UIManager::AddWindow(IXWindow* pWindow)
{
#ifdef _DEBUG
    WindowList::iterator IteWindow = std::find(m_listWindow.begin(), m_listWindow.end(), pWindow);
    XASSERT_ERROR(IteWindow == m_listWindow.end(), _T("Window Added Twice!"));
#endif // _DEBUG

    m_listWindow.push_back(pWindow);
}

void UIManager::RemoveWindow(IXWindow* pWindow)
{
    WindowList::iterator IteWindow = std::find(m_listWindow.begin(), m_listWindow.end(), pWindow);
    XASSERT_ERROR(IteWindow != m_listWindow.end(), _T("Window Not Added!"));
    if(IteWindow != m_listWindow.end())
    {
        m_listWindow.erase(IteWindow);
    }
}

void UIManager::RemoveAllWindow()
{
    m_listWindow.clear();
}

void UIManager::Check()
{
    XASSERT_ERROR(m_listWindow.size() <= 0, _T("Window Added Twice!"));
}
